import QMFetch from 'fetch/index';
const defaultPageSize = 12;
const defaultPage = 0;

//获取普通图文的信息
export const getNewsInfo = ({ page = defaultPage, pageSize = defaultPageSize }) => QMFetch({
    url: `api/material/list/news`,
    method: 'GET',
    body: {
        page,
        pageSize,
        _: Date.now()
    }
});

//获取高级图文的信息
export const getAdNewsInfo = ({ page = defaultPage, pageSize = defaultPageSize }) => QMFetch({
    url: `api/advancedNews/list`,
    method: 'GET',
    body: {
        page,
        pageSize,
        _: Date.now()
    }
});

//更新某条图文里的某条消息
export const updateInfoInNews = ({
    media_id,
    index,
    articles
}) => QMFetch({
        url: `api/material/${media_id}/update`,
        method: 'POST',
        body: {
            index,
            articles
        }
    })

//新增某条图文信息
export const addNewsInterface = (articles) => QMFetch({
    url: `api/material/upload/article`,
    method: 'POST',
    body: {
        articles
    }
})

//删除一条图文
export const delNews = (media_id) => QMFetch({
    url: `api/material/${media_id}/delete`,
    method: 'POST'
})

//更新某条【高级】图文里的某条消息
export const updateInfoInAdvancedNews = ({
    media_id,
    index,
    articles
}) => QMFetch({
        url: `api/advancedNews/update`,
        method: 'POST',
        body: {
            id: media_id,
            index,
            articles
        }
    })

//新增某条【高级】图文信息
export const addAdvancedNewsInterface = (articles) => QMFetch({
    url: `api/advancedNews/create`,
    method: 'POST',
    body: {
        articles
    }
})

//删除一条【高级】图文
export const delAdvancedNews = (media_id) => QMFetch({
    url: `api/advancedNews/delete`,
    method: 'POST',
    body: {
        id: media_id
    }
})